//
//  DetailsBannerView.m
//  Cat
//
//  Created by lushitong on 2018/12/23.
//  Copyright © 2018年 lushitong. All rights reserved.
//

#import "DetailsBannerView.h"

@interface DetailsBannerView()

@property (nonatomic, strong) UIView *operView;
@property (nonatomic, strong) UIView *leftView;
@property (nonatomic, strong) UILabel *leftLabel;
@property (nonatomic, strong) UIView *rightView;
@property (nonatomic, strong) UILabel *rightLabel;

@end

@implementation DetailsBannerView

- (void)setCouponNumber:(NSString *)couponString withPrizeAmount:(NSString *)prizeAmount {
	self.leftLabel.text = [NSString stringWithFormat:@"%@元券",couponString];
	self.rightLabel.text = [NSString stringWithFormat:@"预估佣金￥%@",prizeAmount];
}

- (instancetype)initWithFrame:(CGRect)frame {
	self = [super initWithFrame:frame];
	if (self) {
		self.backgroundColor = [UIColor whiteColor];
		[self loadAllSubViews];
	}
	return self;
}

- (void)loadAllSubViews {
	[self addSubview:self.operView];
	
	[self.operView addSubviews:@[self.leftView,self.leftLabel,self.rightView,self.rightLabel]];
	
	[self.operView mas_makeConstraints:^(MASConstraintMaker *make) {
		make.edges.equalTo(self);
	}];
	
	[self.leftView mas_makeConstraints:^(MASConstraintMaker *make) {
		make.left.and.top.and.bottom.equalTo(self.operView);
		make.width.equalTo(@(kQKFitModuleDecimal(77)));
	}];
	
	[self.leftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
		make.edges.equalTo(self.leftView);
	}];
	
	[self.rightView mas_makeConstraints:^(MASConstraintMaker *make) {
		make.left.equalTo(self.leftView.mas_right);
		make.top.and.right.top.and.bottom.equalTo(self.operView);
	}];
	
	[self.rightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
		make.centerY.equalTo(self.rightView.mas_centerY);
		make.left.equalTo(self.rightView.mas_left).offset(kQKFitModuleDecimal(14.0));
	}];
}

#pragma mark----- lazy init -----

- (UIView *)operView {
	if (!_operView) {
		_operView = [[UIView alloc] init];
		_operView.backgroundColor = [UIColor whiteColor];
		_operView.layer.cornerRadius = kQKFitModuleDecimal(6.0);
	}
	return _operView;
}

- (UIView *)leftView {
	if (!_leftView) {
		_leftView = [[UIView alloc] init];
		_leftView.backgroundColor = COLOR_WITH_HEX(0xFE5F53);
	}
	return _leftView;
}

- (UILabel *)leftLabel {
	if (!_leftLabel) {
		_leftLabel = [UILabel labelWithFont:[UIFont boldSystemFontOfSize:SWScaleFromInch47 * 16] textColor:[UIColor whiteColor]];
		_leftLabel.textAlignment = NSTextAlignmentCenter;
	}
	return _leftLabel;
}

- (UIView *)rightView {
	if (!_rightView) {
		_rightView = [[UIView alloc] init];
		_rightView.backgroundColor = COLOR_WITH_HEX(0xFFC236);
	}
	return _rightView;
}

- (UILabel *)rightLabel {
	if (!_rightLabel) {
		_rightLabel = [UILabel labelWithFont:[UIFont systemFontOfSize:SWScaleFromInch47 * 14] textColor:COLOR_WITH_HEX(0x57524F)];
		_rightLabel.textAlignment = NSTextAlignmentCenter;
	}
	return _rightLabel;
}

@end
